package com.yisu.auction.api.core.service.impl;

import com.yisu.auction.api.core.mapper.SmsMapper;
import com.yisu.auction.api.core.service.BaseService;
import com.yisu.auction.api.core.service.ISmsService;
import com.yisu.auction.ewf.entity.Sms;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * author: 赵杰
 * Business Description：
 * createTime：2017/8/25
 */
@Service("ISmsService")
public class SmsServiceImpl extends BaseService implements ISmsService{
    @Resource
    private SmsMapper smsMapper;
    /**
     * 添加验证码
     *
     * @param sms
     * @return
     */
    @Override
    public boolean addValidateCode(Sms sms) {
        return smsMapper.insertSelective(sms)>0;
    }

    /**
     * 通过手机号获取验证码
     *
     * @param mobile
     * @return
     */
    @Override
    public Sms getValidateCodeByMobile(String mobile) {
        return smsMapper.getValidateCodeByMobile(mobile);
    }

    /**
     * 修改验证码状态
     *
     * @param updateModel 修改对象
     * @return
     */
    @Override
    public boolean updateValidateCode(Sms updateModel) {
        return smsMapper.updateByPrimaryKeySelective(updateModel)>0;
    }
}
